const local = window.localStorage;
export default {
  //获取本地数据
  getLocalDataEvent(code) {
    let queryCode = '';
    //pc蛋蛋 - 007   加拿大28 - 013
    if (code === '007' || code === '013' || code === '1001') {
      queryCode = '007';
    } else if (code === '009') {
      queryCode = '009';
    } else if (code === '014' || code === '1003') {
      queryCode = '014';
    } else if (code === '2002') {
      queryCode = '2002';
    } else {
      queryCode = '';
    }
    return queryCode;
  },
  getSelectEvent(code) {
    let codeData = '';
    if (code === '001' || code === '002') {
      codeData = '001';
    }
    if (code === '003' || code === '004') {
      codeData = '003';
    }
    if (code === '005' || code === '006') {
      codeData = '005';
    }
    if (code === '010' || code === '011') {
      codeData = '010';
    }
    if (code === '015' || code === '016') {
      codeData = '015';
    }
    if (code === '017' || code === '018') {
      codeData = '017';
    }
    return codeData;
  },
  //不同开奖结果判定
  differentAwards(code) {
    let openA = {
      pcVery: false, //pc蛋蛋
      choose: false, //广东11选5
      happy: false,  //快乐六合彩
      fastT: false, //江苏快三
      BJpk10: false, //北京pk10
      BJHappy8: false, //北京快乐8
      bigWheel: false,//大转盘
      baccarat: false,//百家乐
    };
    switch (code) {
      case '001':
      case '002':
      case '003':
      case '004':
      case '012':
      case '015':
      case '016':
      case '017':
      case '018':
      case '019':
      case '020':
      case '021':
      case '022':
      case '025':
        openA.choose = true;
        break;
      case '005':
      case '006':
      case '1002':
        openA.BJpk10 = true;
        break;
      case '007':
      case '013':
      case '1001':
        openA.pcVery = true;
        break;
      case '008':
      case '026':
        openA.BJHappy8 = true;
        break;
      case '009':
      case '014':
      case '1003':
        openA.happy = true;
        break;
      case '010':
      case '011':
      case '023':
      case '024':
        openA.fastT = true;
        break;
      case '2002':
        openA.bigWheel = true;
        break;
      case '2001':
        openA.baccarat = true;
        break;
    }
    return openA;
  },
  //input 只能输入数字
  inputNumber(val) {
    val = val.replace(/[^\d]/g, '');
    return val
  },
  // 判定是home 还是noHome
  judgeHome(name) {
    let str = "";
    switch (name) {
      case "index":
      case "systemOf":
      case "activity":
      case "helpCenter":
      case "activityDetail":
      case "systemDetails":
        str = "home";
        break;
      default:
        str = "noHome";
        break;
    }
    return str;
  },
  // 判断是调用官方还是信用code
  judgeCode(isDefault, creditCode, officialCode) {
    return parseInt(isDefault) === 2 ? creditCode : officialCode;
  },
  //获取筹码icon
  getChipImg(num) {
    return require('../../../images/theColor/baccarat/chip/' + num + '.png');
  },
  //获取投注区-文字图片
  getTextImg(id) {
    return require('../../../images/theColor/baccarat/bet/' + id + '.png');
  },
  //获取小牌图片
  getSmallCard(type, num) {
    let img = '';
    num = num == '?' ? '_null' : num;
    type = parseInt(type);
    if (num > 0 && num < 14 || num == '_null') {
      switch (type) {
        case 2:
          img = require('../../../images/theColor/baccarat/sCard/block' + num + '.png');
          break;
        case 4:
          img = require('../../../images/theColor/baccarat/sCard/club' + num + '.png');
          break;
        case 1:
          img = require('../../../images/theColor/baccarat/sCard/heart' + num + '.png');
          break;
        case 3:
          img = require('../../../images/theColor/baccarat/sCard/spade' + num + '.png');
          break;
        default:
      }
    }
    return img;
  },
  //获取大牌图片
  getBigCard(type, num) {
    let img = '';
    num = num == '?' ? '_null' : num;
    type = parseInt(type);
    if (num > 0 && num < 14 || num == '_null') {
      switch (type) {
        case 2:
          img = require('../../../images/theColor/baccarat/bigCard/block' + num + '.png');
          break;
        case 4:
          img = require('../../../images/theColor/baccarat/bigCard/club' + num + '.png');
          break;
        case 1:
          img = require('../../../images/theColor/baccarat/bigCard/heart' + num + '.png');
          break;
        case 3:
          img = require('../../../images/theColor/baccarat/bigCard/spade' + num + '.png');
          break;
        default:
      }
    }
    return img;
  },
  // 金币动画
  parabola(that, e, location, index, scrollDistance) {
    // let that = this;
    let flyFunc = function () {
      let chip = location.find(".chip");
      let offsetImg = chip.find("img").offset();
      let chipImg = $(".betChips .chipOn").find("img");
      let chipImgOffset = chipImg.offset();
      let flyer = chipImg.clone();
      
      flyer.attr({
        "class": "cloneImg"
      }).offset({
        top: chipImgOffset.top,
        left: chipImgOffset.left
      }).css({
        "position": "absolute",
        "width": "85px",
        "height": "85px",
        "margin-left": "5px",
        "z-index": "1000"
      });
      flyer.fly({
        speed: 1.8,
        start: {
          left: chipImgOffset.left,
          top: chipImgOffset.top
        },
        end: {
          left: offsetImg.left,
          top: offsetImg.top - (scrollDistance || 0),
          width: 50,
          height: 50
        },
        onEnd: function () {
          chip.find('img').attr('src', flyer.attr('src'));
          let flyThat = this;
          setTimeout(function () {
            flyThat.destroy();
          }, 40);
        }
      });
    };
    flyFunc();
  },
}
